﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Bricks.Business.Service.Impl;
using Bricks.Site.Models;
using Bricks.Business.Models.FlowProcess;
using System.Xml;
using System.Web.Script.Serialization;
using Bricks.Business.Service;
using Bricks.Component.Utils;
using Bricks.Site.Web.CommonUtils;
using Bricks.Component.Utils.Extensions;

namespace Bricks.Site.Web.Controllers
{
    [Export]
    public class SystemProcessMessageController : BaseController
    {
        [Import]
        public ISystemProcessMessageService SystemProcessMessageService { get; set; }

        public ActionResult GetSystemProcessMessageList(int rows = 20, int page = 1)
        {
            List<SystemProcessMessageView> lstSystemProcessMessageView = SystemProcessMessageService.GetSystemProcessMessage(User.Identity.Name);
            int total = lstSystemProcessMessageView.Count;
            var pageLstSystemProcessMessageView = lstSystemProcessMessageView.OrderByDescending(m => m.SendTime).Skip(rows * (page - 1)).Take(rows);
            var result = new { total = total, rows = pageLstSystemProcessMessageView };
            return Json(result, "text/html");
            //return Json(lstSystemProcessMessageView, JsonRequestBehavior.AllowGet);
        }

        public ActionResult DeleteSystemProcessMessage(string id)
        {
            return Json(SystemProcessMessageService.DeleteSystemProcessMessage(id.ToGuid()), JsonRequestBehavior.AllowGet);
        }
    }
}